<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../layui/css/layui.css"/>
    <script src="../jQuery/jquery-1.11.2.js"></script>
    <script src="../layui/layui.js"></script>
    <style>::-webkit-scrollbar{display: none;}</style>
    <link rel="stylesheet" type="text/css" href="/css/font.css">
</head>

<body>
<div>
<div id="jj" lay-filter="jj">
</div>
<button id="aa" style="width: 200px;margin-left: 150px;margin-top: 30px" lay-submit lay-filter="aa" class="layui-btn layui-btn-normal">提交</button>
</div>
</body>
<script>
    $(function () {
        layui.use("transfer",function () {
        var xx=[];


            var tr=layui.transfer;
            var data1 = [
                {funId:"fsy",funName:"首页",isabled:true},
                {funId:"f2",funName:"业务数据"},
                {funId:"f4",funName:"TA管理"},
                {funId:"f5",funName:"库存处理"},
                {funId:"f8",funName:"报表管理"},
                {funId:"f9",funName:"系统管理"},
                {funId:"f6",funName:"业务处理"},
                {funId:"f1",funName:"业务参数"},
                {funId:"f7",funName:"日终处理"},
                {funId:"f3",funName:"现金管理"},
            ]

            tr.render({
                elem: '#jj',
                id:"k",
            })
            $.ajax({
                url:"/fc/qx",
                method: "get",
                success:function (sj) {
                    for (var i=0;i<sj.length;i++){
                        xx[i]=sj[i].funId;
                    }
                    tr.reload('k', {
                        title:['添加权限','我的权限'],
                        data:data1,
                        parseData: function(res){
                            return {
                                "value": res.funId //数据值
                                ,"title": res.funName //数据标题
                                ,"disabled": res.disabled  //是否禁用
                                ,"checked": res.checked //是否选中
                            }
                        },value: xx
                    });
                }

            });
            $("#aa").click(function () {
                var kk="";
                var getData = tr.getData('k');
                for (var j=0;j<getData.length;j++){
                    kk+=getData[j].value+",";
                }
                kk+="f1,fsy,";
                $.ajax({
                    url:"/fc/rqx/"+kk,
                    method: "put",
                    success:function (sj) {
                        if(sj=="cg"){
                            window.parent.layer.closeAll();
                        }else{
                            alert("失败");
                        }
                    }
                });
            });

        })
    });

</script>
</html>